/**
 * author: MaHX
 * date: 2019/8/24/19:41
 * description: 直接插入排序
 **/
public class InsertSort {
    public static void main(String args[]){
        int[] arrs = new int[]{5,7,9,3,7,6,1,0,4};
        for (int i = 1; i < arrs.length; i++) {
            if (arrs[i]<arrs[i-1]){
                for (int j = i; j > 0 ; j--) {
                    if (arrs[j]<arrs[j-1]){
                        int temp = arrs[j];
                        arrs[j] = arrs[j-1];
                        arrs[j-1] = temp;
                    }
                }
            }

        }
        for (int i = 0; i < arrs.length; i++) {
            System.out.println(arrs[i]);
        }
    }
}
